package com.test.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.test.entity.LoginParam;
import com.test.entity.ResultEntity;
import com.test.entity.pojo.UserEntity;
import com.test.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UserController
 * @Discription TODO
 * @Author DaiFuqiang
 * @Date 2022/11/19 22:46
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUserService userService;

    @DeleteMapping("deleteUser")
    public ResultEntity deleteUser(String userName) {
        return userService.deleteByUserName(userName);
    }

    @PostMapping ("editUser")
    public ResultEntity editUser(@RequestBody UserEntity user) {
        UpdateWrapper<UserEntity> wrapper = new UpdateWrapper<>();
        wrapper.eq("id", user.getId());
        userService.update(user, wrapper);
        return new ResultEntity();
    }
}
